#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Author: Faker.Deng
Exercise after Chapter 1 Problem 4
"""
import math


# Problem 4
def calculate_pi_div4():
    """
    Calculate PI / 4 Approximate value
    :return: None
    """
    pi_div4 = 0
    count = int(input("Please input calculate times: "))
    for i in range(count):
        pi_div4 += math.pow(-1.0, i)/((i + 1) * 2 - 1)
    print(" \"PI/4\" approximately equal to", pi_div4)
    return


if __name__ == "__main__":
    calculate_pi_div4()
